<template>
  <div>
      <h1>登录</h1>
      <p>账号:<input type="text" v-model="username"></p>
      <p>密码:<input type="text" v-model="password"></p>
      <p><button @click="login">登录</button></p>

  </div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
      baseurl:'http://127.0.0.1:8000',
      username:'',
      password:'',

    }
  },
  methods:{
      login(){
        axios({
          url:'http://127.0.0.1:8000/app01/author/',
          method:'post',
          data:{'username':this.username,'password':this.password}
        }).then(res=>{
          console.log(res.data)
          sessionStorage.setItem('id',res.data.id)
          sessionStorage.setItem('user',res.data.user)
          // 双引号里的是前后端对应的
        })
      }
  }

}
</script>

<style>

</style>